// 1.默认导入material风格的组件库
import 'package:flutter/material.dart';

class MyApp14 extends StatelessWidget {
  const MyApp14({super.key});

  List<Widget> getList() {
    return [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((int value) {
      return Container(
        width: double.infinity,
        height: 100,
        margin: const EdgeInsets.all(10),
        alignment: Alignment.center,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(35),
          color: Colors.blue,
        ),
        child: Text(
          '我是第$value个item',
          style: const TextStyle(color: Colors.white),
        ),
      );
    }).toList();
  }

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    // 3.创建一个MaterialApp组件（指定应用整体的UI风格：material风格）
    return Scaffold(
        // 1.1 导航
        appBar: AppBar(
          title: const Text('ListView组件'),
          backgroundColor: Colors.pink,
        ),
        // 1.2 主体内容
        body: ListView.builder(
          itemBuilder: (BuildContext context, int index) {
            return Container(
              width: double.infinity,
              height: 100,
              margin: const EdgeInsets.all(10),
              alignment: Alignment.center,
              decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(35),
                color: Colors.blue,
              ),
              child: Text(
                '我是第$index个item',
                style: const TextStyle(color: Colors.white),
              ),
            );
          },
          itemCount: 20,
        ));
  }
}
